package org.spbsu.apco.common.monitoring.event;

import java.io.Serializable;
import java.util.concurrent.atomic.AtomicLong;

/**
 * User: Anton Ovchinnikov
 * Date: 1/10/13
 * Time: 3:04 PM
 */
public abstract class BaseEvent implements Serializable, Cloneable {

    protected String eventId;
    protected String originatorId;
    protected String taskId;
    protected long taskStartTime;
    protected long taskDuration;

    private static AtomicLong nextEventId = new AtomicLong(0);

    private static String getNewEventId() {
        return nextEventId.getAndIncrement() + "";
    }

    public void generateNewId() {
        eventId = getNewEventId();
    }

    public String getEventId() {
        return eventId;
    }

    public void setEventId(String eventId) {
        this.eventId = eventId;
    }

    public String getOriginatorId() {
        return originatorId;
    }

    public void setOriginatorId(String originatorId) {
        this.originatorId = originatorId;
    }

    public String getTaskId() {
        return taskId;
    }

    public void setTaskId(String taskId) {
        this.taskId = taskId;
    }

    public long getTaskStartTime() {
        return taskStartTime;
    }

    public void setTaskStartTime(long taskStartTime) {
        this.taskStartTime = taskStartTime;
    }

    public long getTaskDuration() {
        return taskDuration;
    }

    public void setTaskDuration(long taskDuration) {
        this.taskDuration = taskDuration;
    }

    public static AtomicLong getNextEventId() {
        return nextEventId;
    }

    public static void setNextEventId(AtomicLong nextEventId) {
        BaseEvent.nextEventId = nextEventId;
    }

    @Override
    public Object clone() throws CloneNotSupportedException {
        return super.clone();    //To change body of overridden methods use File | Settings | File Templates.
    }
}
